﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form

    {
        int n = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            disknumberCombobox.Focus();
            runButton.Enabled = false;
            resetButton.Enabled = false;
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            DialogResult des = MessageBox.Show("Are you sure?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (des == DialogResult.Yes)
                Environment.Exit(0);
            else
                e.Cancel = true;
        }

        private void Create_Click(object sender, EventArgs e)
        {
            try
            {
                n = int.Parse(disknumberCombobox.Text);
                if (n > 1 && n < 11)
                {
                    processPanel.create(n);
                    stepstaken_Listview.Items.Add("Add disks sussesfully");
                    createButton.Enabled = false;
                    runButton.Enabled = true;
                    resetButton.Enabled = true;
                }
                else
                {
                    MessageBox.Show("Number of Disk error! Please try again", "", MessageBoxButtons.OK);
                    disknumberCombobox.Focus();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Number of Disk error! Please try again", "", MessageBoxButtons.OK);
                disknumberCombobox.Focus();
            };

        }

        private void Run_Click(object sender, EventArgs e)
        {
            
        }

        private void Reset_Click(object sender, EventArgs e)
        {
            processPanel.Controls.Clear();
            stepstaken_Listview.Items.Clear();
            disknumberCombobox.Text = "";
            createButton.Enabled = true;
            runButton.Enabled = false;
            resetButton.Enabled = false;
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult des = MessageBox.Show("Are you sure?", "Exit",MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
            if (des == DialogResult.Yes)
                Environment.Exit(0);            
        }

        private void infomationToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutBox1 about = new AboutBox1();
            about.Show();
        }

        //////////////////////////////////////////////////////////////////////////////////////////

    }

}
